<!--#
layout("/layouts/platform.html"){
#-->
<style>
    .el-upload input[type=file] {
        display: none;
    }

    .el-upload__text {
        color: #606266;
        font-size: 14px;
        text-align: center;
    }
</style>
<div id="app"  v-cloak>
    <el-row class="header navbar bg-white">
        <div class="btn-group tool-button" style="line-height: 50px;">
            设备编号：<el-input placeholder="设备编号" v-trim v-model="pageForm.code" size="mini" style="width:180px;" clearable></el-input>
            设备名称：<el-input placeholder="设备名称" v-trim v-model="pageForm.name" size="mini" style="width:180px;" clearable></el-input>
            年份：<el-date-picker type="year" placeholder="年份" v-trim v-model="pageForm.year" size="mini" value-format="yyyy"  style="width: 180px;"></el-date-picker>
            <el-button slot="append" icon="el-icon-search" size="mini" @click="doSearch" circle></el-button>

        </div>
    </el-row>

    <el-row class="el-table-container">
        <el-table :data="tableData" @sort-change='pageOrder' height="520"  border size="small" header-align="center"  style="width: 100%" >

            <el-table-column fixed="left" sortable="custom" prop="code" label="设备编号" width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column fixed="left" sortable="custom" prop="name" label="设备名称" width="200px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="recordcount" label="使用次数" width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="servicingcount" label="维修次数" width="220px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="statuscount" label="停用次数" width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="portablecount" label="借出次数" min-width="130px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="checkcount" label="维护次数" min-width="130px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="inspectioncount" label="送检次数" min-width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="reportcount" label="确认次数" width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
        </el-table>
    </el-row>
    <el-row class="el-pagination-container">
        <el-pagination @size-change="pageSizeChange" @current-change="pageNumberChange" :current-page="pageForm.pageNumber" :page-sizes="[10, 20, 30, 50]"
                       :page-size="pageForm.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageForm.totalCount">
        </el-pagination>
    </el-row>
</div>
<style scoped>
    .el-table--border th.gutter:last-of-type {
        display: block !important;
        width: 17px !important;
    }

</style>
<script>
    var allMap = {}
    new Vue({
        el: "#app",
        data: function () {
            return {
                allMap:allMap,
                tableData: [],
                addDialogVisible:false,
                pageForm: {year:"${nowYear}"},
            }
        },
        methods: {
            pageOrder: function (column) {//按字段排序
                this.pageForm.pageOrderName = column.prop;
                this.pageForm.pageOrderBy = column.order;
                this.pageData();
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            pageData: function () {//加载分页数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/bus/reports/equipmentCount/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        self.tableData = data.data.list;
                        self.pageForm.totalCount = data.data.totalCount;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            doSearch: function () {
                if(!nONull(this.pageForm.year)){
                    this.pageForm.year="${nowYear}"
                }
                this.pageForm.pageNumber = 1;
                this.pageData();
            },
            doClear:function(){
                this.allMap.listSelect.forEach((item,index)=>{
                    if(item.condition=='drop'){
                        item.value=[];
                    }else if(item.condition=='like'||item.condition=='number'){
                        item.value="";
                    }else{
                        item.startDate = "";
                        item.endDate = "";
                    }
                })
                this.allMap.listSelect=JSON.parse(JSON.stringify(this.allMap.listSelect));
            },
            getDict: function (val,map) {
                if (val!= null && val!=undefined &&val!="" &&val!="null" &&val!="undefined" && map!=null && map !=undefined){
                    var str = val.split(",");
                    var strname="";
                    for (var a=0;a<str.length;a++){
                        strname+=map[str[a]];
                        if(strname == null){
                            alert(1)
                        }
                        if(a<(str.length-1)){
                            strname+="/";
                        }
                    }
                    return strname;
                }
                return "";
            },

        },
        created: function () {
            this.doSearch();
        }
    });

    function nONull(val){
        if (val!= null && val!=undefined &&val!="" &&val!="null" &&val!="undefined" ){
            return true;
        }else{
            return false;
        }
    }
</script>
<!--#
}
#-->
